<!DOCTYPE html>
<html lang="en">
<head>
    
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalble=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>

        @keyframes spin{
            0%{
                transform: rotate(0);
            }
            100%{
                transform: rotate(360deg);
            }
        }

        html{
            height: 100%;
        }
        body{
            margin: 0;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;

            background: radial-gradient(white,#999999);
        }
        #bg{
            width: 500px;
            height: 500px;
            /* border: solid 1px black; */
            /* 相对于离自己最近的，position为非static的祖先元素进行定位 */
            position: relative;
        }
        .dot{
            width: 5px;
            height: 5px;
            border-radius: 50%;
            background-color: black;
            position: absolute;
        }

        #center-dot{
            width: 20px;
            height: 20px;
            position: absolute;
            left: calc(50% - 10px);
            top: calc(50% - 10px);
            background-color: black;
            border-radius: 50%;
            z-index: 10;
        }

        .pointer{
            position: absolute;
            animation-name: spin;
            animation-timing-function: linear;
            animation-iteration-count: infinite;
        }

        #second-pointer{
            width: 2px;
            height: 300px;
            background-color: red;
            left: 249px;
            z-index: 5;
            border-top-left-radius: 50%;
            border-top-right-radius: 50%;
            animation-duration: 60s;
            transform-origin: 50% 83.5%;

        }
        #minute-pointer{
            top: 40px;
            width: 8px;
            height: 240px;
            background-color: black;
            left: 246px;
            z-index: 4;
            border-radius: 4px;
            animation-duration: 3600s;
            transform-origin: 50% 87.5%;
        }
        #hour-pointer{
            top: 60px;
            width: 12px;
            height: 210px;
            background-color: black;
            left: 244px;
            z-index: 3;
            border-radius: 8px;
            animation-duration: 43200s;
            transform-origin: 50% 90.5%;
        }

        .num{
            position: absolute;
            width: 26px;
            height: 26px;
            text-align: center;
            line-height: 26px;
            font-size: 26px;
        }
        
    </style>
</head>
<body>
    
    <div id="bg">
        <div id="center-dot"></div>
        <div id="second-pointer" class="pointer"></div>
        <div id="minute-pointer" class="pointer"></div>
        <div class="pointer" id="hour-pointer"></div>
    </div>
    
</body>

<script>

    var bg = document.getElementById("bg");
    
    for(var i = 0;i<60;i++)
    {
        var dot = document.createElement("div");
        dot.classList.add("dot");

        var angle = i*6;
        
        angle = angle/180*Math.PI;

        if(i%5==0){
            dot.style.width = "10px";
            dot.style.height = "10px";
            var x = 250 + 240*Math.cos(angle) - 5;
            var y = 250 + 240*Math.sin(angle) - 5;

            var num = document.createElement("div");
            num.classList.add("num");
            var numX = 250 + 210*Math.cos(angle-Math.PI/3) - 13;
            var numY = 250 + 210*Math.sin(angle-Math.PI/3) - 13;
            num.style.left = numX+"px";
            num.style.top = numY+"px";
            num.textContent = i/5+1;
            bg.appendChild(num);

            
        }else{
            var x = 250 + 240*Math.cos(angle) - 2.5;
            var y = 250 + 240*Math.sin(angle) - 2.5;
        }

        
        dot.style.left = x+"px";
        dot.style.top = y+"px";

        bg.appendChild(dot);
    }

    var secondPointer = document.getElementById("second-pointer");
    var minutePointer = document.getElementById("minute-pointer");
    var hourPointer = document.getElementById("hour-pointer");

    var now = new Date();
    var h = now.getHours();
    var m = now.getMinutes();
    var s = now.getSeconds();
    var delay = h*3600+m*60+s;

    secondPointer.style.animationDelay = -delay+"s";
    minutePointer.style.animationDelay = -delay+"s";
    hourPointer.style.animationDelay = -delay+"s";



</script>




</html>


